﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using CashierSystem.CustomerManager;
using CashierSystem.UserManager;
using CashierSystem.SearchAccountManager;
using CashierSystem.CheckItemManager;
using CashierSystem.remindManager;
using CashierSystem.DoctorRecordManager;
using CashierSystem.CashierInManager;

namespace CashierSystem
{
    public partial class Form1 : Form
    {
        public User user;
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            LoginForm lf = new LoginForm();
            lf.ShowDialog();
            user = lf.getUser();
            if (!lf.getResult())
            {
                this.Close();
            }
            else
            {
                setMenuShow();
                string name = UserManagerAction.getUserName(user.getAccount());
                label2.Text = "现在登录的是 " + name + "，以下是你的提醒内容";
                UserRemindManager.loadRemind(listView1,user.getAccount());
            }


        }
        private void setMenuShow()
        {

            if (!user.isRole("系统管理员"))
            {
                查询账目ToolStripMenuItem.Visible = false;
                用户管理ToolStripMenuItem.Visible = false;
                检测项目管理ToolStripMenuItem.Visible = false;

            }
            if (user.isRole("专家"))
            {
                查询账目ToolStripMenuItem.Visible = false;
                用户管理ToolStripMenuItem.Visible = false;
                检测项目管理ToolStripMenuItem.Visible = false;
                会员录入ToolStripMenuItem.Visible = false;
                收银ToolStripMenuItem.Visible = false;
            }


            /*if (!user.isRole("教务员"))
            {
                学生管理ToolStripMenuItem.Visible = false;
                教师管理ToolStripMenuItem.Visible = false;

                输入ToolStripMenuItem.Visible = false;
                修改ToolStripMenuItem1.Visible = false;
                查询ToolStripMenuItem.Visible = false;
                输入ToolStripMenuItem2.Visible = false;
                修改ToolStripMenuItem3.Visible = false;
            }
            if (!user.hasRight("开课查询"))
            {
                开课查询ToolStripMenuItem.Visible = false;
            }*/

        }


      /*  private void 挂号ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            NewCustomerForm ncf = new NewCustomerForm();
            ncf.StartPosition = FormStartPosition.CenterScreen;
            ncf.ShowDialog();
        }*/

        private void 已有客户查询与挂号ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            SearchOldCustomerForm socf = new SearchOldCustomerForm(user);
            socf.StartPosition = FormStartPosition.CenterScreen;
            socf.ShowDialog();
        }

        /*private void 查询账目ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            SearchAccountForm saf = new SearchAccountForm();
            saf.StartPosition = FormStartPosition.CenterScreen;
            saf.ShowDialog();
        }
        */
        private void 用户管理ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            UserManagerForm umf = new UserManagerForm();
            umf.StartPosition = FormStartPosition.CenterScreen;
            umf.ShowDialog();
        }

        private void 添加新项目ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            AddCheckItemForm acif = new AddCheckItemForm();
            acif.StartPosition = FormStartPosition.CenterScreen;
            acif.ShowDialog();
        }

        private void 更新项目ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            UpdateItemForm uif = new UpdateItemForm();
            uif.StartPosition = FormStartPosition.CenterScreen;
            uif.ShowDialog();
        }

        private void 会员录入ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            NewCustomerForm ncf = new NewCustomerForm();
            ncf.StartPosition = FormStartPosition.CenterScreen;
            ncf.ShowDialog();
        }

        private void 提醒录入ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            NewRemindForm nrf = new NewRemindForm(user);
            nrf.StartPosition = FormStartPosition.CenterScreen;
            nrf.ShowDialog();
        }

        private void 更改与删除ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            SearchRemindForm srf = new SearchRemindForm(user);
            srf.StartPosition = FormStartPosition.CenterScreen;
            srf.ShowDialog();
        }

        private void button2_Click(object sender, EventArgs e)
        {
            setMenuShow();
            string name = UserManagerAction.getUserName(user.getAccount());
            label2.Text = "现在登录的是 " + name + "，以下是你的提醒内容";
            UserRemindManager.loadRemind(listView1, user.getAccount());
        }

        private void 添加或更新诊疗记录ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            SearchRecordForm srf = new SearchRecordForm(user);
            srf.StartPosition = FormStartPosition.CenterScreen;
            srf.ShowDialog();
        }

        private void 查询所有诊疗ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            SearchAllRecordForm sarf = new SearchAllRecordForm();
            sarf.StartPosition = FormStartPosition.CenterScreen;
            sarf.ShowDialog();
        }

        private void 查询详细ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            SearchAccountForm saf = new SearchAccountForm();
            saf.StartPosition = FormStartPosition.CenterScreen;
            saf.ShowDialog();
        }

        private void 查询卡详细ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            SearchCardForm scf = new SearchCardForm();
            scf.StartPosition = FormStartPosition.CenterScreen;
            scf.ShowDialog();
        }

    }
}